-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AN/USER] 안드로이드 네비게이션을 적용한다. (#758) #781
Conversation
# Conflicts: # android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt # android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt # android/festago/presentation/src/main/res/drawable/ic_bookmark_normal.xml
# Conflicts: # android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt # android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailFragment.kt # android/festago/presentation/src/main/res/layout/fragment_school_detail.xml
# Conflicts: # android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt # android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
상태바가 흰색으로 변경되게 만들었었는데 안되네요. backStack 이 변경되지 않아서 리스터가 동작하지 않습니다!
임시로 myPage 에 네비게이션 그래프를 추가해봤는데 스택이 따로 저장되네요! 이러면 fragment manager 4개로 관리할 필요는 없겠군요!
네비게이션이 생각보다 복잡하군요. 코멘트 확인해주세요!
if (_binding == null) { | ||
_binding = FragmentArtistDetailBinding.inflate(inflater) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 화면으로 navigate 할 때 항상 onDestroyView 가 불립니다.
- 네비게이션 action 은 무조건 replace 인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null로 만들어주는게 onDestory인줄 알았는데 착각했네요
찾아보니 네비게이션 action은 무조건 replace로 작동하고
add처럼 동작하려면 dialog태그를 사용해야합니다.
fun loadFestivalDetail(festivalId: Long, refresh: Boolean = false) { | ||
if (!refresh && _uiState.value is FestivalDetailUiState.Success) return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
예전에 기억이 잘 안나서 그런데
새로고침 요청이 아니고 Success 라면 서버에 재요청하지 않으려고 막은거였죠?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 initView() 호출될때마다 불필요하게 load 다시하는 거 막으려고 했던거로 기억합니당
navController = | ||
(supportFragmentManager.findFragmentById(R.id.fcvHomeContainer) as NavHostFragment).navController | ||
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.nvHome) | ||
bottomNavigationView.setupWithNavController(navController) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네비게이션 버튼을 클릭해서 이동할때는 괜찮은데 뒤로가기 누르면 홈에 쌓였던 것들이 초기화되네요..흠 왜 그런걸까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NavigationUI 내부적으로 첫번째 destination으로 popup 하게 되어있어서 그런 것 같아요.
bottom navigation menu item에 menuCategory를 secondary로 두면 탭 이동도 백스택 관리할 수 있어요! 아래 링크 참고
https://hide1202.github.io/android/navigation-backstack/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오 감사합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
베르
- 사실 네비게이션 버튼 이동 시에 뒤로가기 누르면 홈에 쌓인 것들이 초기화 되는 것처럼 보이지만 그 상태에서 다시 홈을 누르면 홈의 스택이 다시 올라옵니다!
해시 - 네비게이션 전략은 다양하게 선택될 수 있을 것같은데 해시가 링크해준게 좋다고 생각해서 반영했습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 👍 코멘트 확인해 주세요!
if (_binding == null) { | ||
_binding = FragmentFestivalDetailBinding.inflate(inflater) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null이 아닌 게 어떤 경우인가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
베르가 말해준 생명주기를 보고 롤백했습니다.
fun loadFestivalDetail(festivalId: Long, refresh: Boolean = false) { | ||
if (!refresh && _uiState.value is FestivalDetailUiState.Success) return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 initView() 호출될때마다 불필요하게 load 다시하는 거 막으려고 했던거로 기억합니당
navController = | ||
(supportFragmentManager.findFragmentById(R.id.fcvHomeContainer) as NavHostFragment).navController | ||
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.nvHome) | ||
bottomNavigationView.setupWithNavController(navController) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NavigationUI 내부적으로 첫번째 destination으로 popup 하게 되어있어서 그런 것 같아요.
bottom navigation menu item에 menuCategory를 secondary로 두면 탭 이동도 백스택 관리할 수 있어요! 아래 링크 참고
https://hide1202.github.io/android/navigation-backstack/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 코드 제가 제거했던 것 같은데 다시 살아났네요..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해시가 작업한 커밋이 PR에 포함되어있네요..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
병렬 작업을 위해 해시 PR 브랜치로 타겟으로 했어요
분기 후에 코드 제거를해서 그런지 살아있는거 같네요
@@ -1,27 +1,27 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<item | |||
android:id="@+id/itemFestival" | |||
android:id="@+id/festivalList" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프래그먼트 정책 변경 및 버그 수정 확인했습니다!
축제 목록 to 축제 상세
animation 만 추가하고 머지합니다!
is SchoolDetailFragment, | ||
-> false | ||
private fun initDestinationChangedListener() { | ||
navController.addOnDestinationChangedListener { _, destination, _ -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addOnDestinationChangedListener 도 있군요! 또 배워갑니다!
📌 관련 이슈
✨ PR 세부 내용
safeargs
을 통해서 인자를 받게 됩니다.findNavController().navigate( FestivalListFragmentDirections.actionFestivalListFragmentToArtistDetailFragment( artistId, ), )
festivalList
처럼 변하게 되었는데 해당 id가 프래그먼트와 같아야지 동작하게 되서 변경하게 되었습니다.